<?php


namespace App\backend\services;


use App\backend\models\OrdersModel;
use App\common\services\BaseServices;
use App\Exceptions\InvalidRequestException;

class OrdersServices extends BaseServices
{

    public $logFile = 'OrdersServices';

    public function __construct()
    {

    }

    /**
     * 获取 - 商品列表
     *
     * @param $data //请求参数数组
     * @return array
     */
    public function getOrdersList($data)
    {
        $page = !isset($data['page']) ? 1 : $data['page'];unset($data['page']);
        $limit = !isset($data['limit']) ? 10 : $data['limit'];unset($data['limit']);

        $where_data = [];
        if (isset($data['title']) && !empty($data['title'])) {
            $where_data[] = ['title','like',"%{$data['title']}%"];
        }

        $select_data = ['id', 'uid', 'order_sn', 'price', 'create_time'];
        $list = OrdersModel::listed($page, $limit, $where_data, [], $select_data);
        if (empty($list)) {
            throw new InvalidRequestException(10009);
        }

        return $list;
    }

}
